﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Lemon2
{
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * enter a string s, if s is valid, return true.
     * @param s string字符串 string s
     * @return bool布尔型
     */
    public bool isValid(string s)
    {
        // write code here
        //先在这一层里面找到abc，然后把剩下的合并放到下一层

        char[] chars = s.ToCharArray();
        

        return myIsValid(chars, s.Length);
    } public bool myIsValid(char[] s,int len)
    {
        if(len==0) return true;

        //打印当前层
        for (int i = 0; i < len ; i++)
        {
            Console.Write(s[i]);
        }
        Console.WriteLine();
        // write code here
        //先在这一层里面找到abc，然后把剩下的合并放到下一层
        for (int i = 0;i<len-2;i++)
        {
            if (s[i] == 'a')
            {
                if (s[i+1] == 'b')
                {
                    if (s[i+2] == 'c')
                    {

                        //后面的向前面移动
                        for(int j = i; j < len-3; j++)
                        {
                            s[j] = s[j + 3];

                        }


                        return myIsValid( s,len-3);
                    }
                }
            }
        }

        return false;
    }


}
public class ProgramLemon2
{
    public static void MainLemon2()
    {

        //string s = "aabcbc";
        //string s = "abccba";
        string s = "abcabcababcc";
        Lemon2 lemon2 = new Lemon2();
 bool res=        lemon2.isValid(s);
        Console.WriteLine(res);

    }
}